//
//  GTMeViewController.m
//  GiftTalk
//
//  Created by Wan on 16/3/22.
//  Copyright © 2016年 Wan. All rights reserved.
//

#import "GTMeViewController.h"
#import "GTMeHeaderView.h"
#import "GTSettingViewController.h"
#import "GTMeSegment.h"

@interface GTMeViewController () <UIScrollViewDelegate>
/** 头部视图 */
@property (weak, nonatomic) GTMeHeaderView *headerImageView;
/** 容器 */
@property (weak, nonatomic) UIScrollView *scrollViewContainer;

@end

static const CGFloat GTMeHeaderViewH = 280;

@implementation GTMeViewController

- (GTMeHeaderView *)headerImageView {
    if (!_headerImageView) {
        GTMeHeaderView *headerView = [GTMeHeaderView headerView];
        headerView.frame = CGRectMake(0, 0, GTScreenW, GTMeHeaderViewH);
        _headerImageView = headerView;
    }
    return _headerImageView;
}

- (UIScrollView *)scrollViewContainer {
    if (!_scrollViewContainer) {
        UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, GTScreenW, GTScreenH)];
        scrollView.contentSize = CGSizeMake(GTScreenW, GTScreenH + 10);
        scrollView.userInteractionEnabled = YES;
        scrollView.showsVerticalScrollIndicator = NO;
        scrollView.delegate = self;
        [self.view addSubview:scrollView];
        _scrollViewContainer = scrollView;
    }
    return _scrollViewContainer;
}

#pragma mark - Lift Cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationController.navigationBarHidden = YES;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = GTBackgroundColor;
    
    [self.scrollViewContainer addSubview:self.headerImageView];
    
    [self buildingSegementView];
    
    [self setupCommentsTableView];
}


#pragma mark - Create UI

- (void)buildingSegementView {
    CGFloat height = GTMeHeaderViewH + 10;
    UIView *segement = [GTMeSegment segment];
    segement.frame = CGRectMake(0, height, GTScreenW, 44);
    segement.backgroundColor = [UIColor whiteColor];
    [self.scrollViewContainer addSubview:segement];
}


- (void)setupCommentsTableView {
    CGRect frame = CGRectMake(0, GTMeHeaderViewH + 54, GTScreenW, GTScreenH);
    UITableView *tableView = [[UITableView alloc] initWithFrame:frame];
    [self.scrollViewContainer addSubview:tableView];

    tableView.rowHeight = UITableViewAutomaticDimension;
    tableView.estimatedRowHeight = 80;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}


- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}


@end
